package serverTier;

import java.util.List;
import java.util.Set;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import DataAccess.DataAccessInterface;
import domain.*;
 


//Service class
@Stateless
public class Access implements  AccessInterfaceLocal{
	
	@EJB
	private DataAccessInterface dao;/* = new AnimalDataAccess();*/
	//@Resource
	//private SessionContext glassfish;  //the more complicated version mod11pg6
	
	@Override
	public void addUser(AccUser newAnimal) //throws SystemUnavailableException//the more complicated version mod11pg6
	{
		dao.addUser(newAnimal);
		//throw new NullPointerException(); mod11p2
		//try{   											//the more complicated version mod11pg6
			//payrollSystem.enrollGPU(newAnimal);	//mod11p4
		//}													//the more complicated version mod11pg6
		/*catch (SystemUnavailableException ne)		     	 //the more complicated version mod11pg6
		{
			glassfish.setRollbackOnly();
			throw ne;
		}*/
	}

	@Override
	public List<AccUser> getAllUser() {
		return dao.findAll();
	}

	@Override
	public AccUser searchbByEmail(String namne){ 
		return dao.findByEmail(namne);
	}
	
	

	@Override
	public void RemoveUser(int Mid) {
		dao.RemoveGPU(Mid);
		
	}

    @Override
    public void addRef(String email,Reference newRef) {
dao.addRef(email,newRef);
        }



    @Override
    public void addAuthor(String email, Author newAuthor) {
          dao.addAuthor(email,newAuthor);
    }

    @Override
    public Author searchbByANAME(String name) {
        return dao.searchbByANAME(name);
    }
    
    @Override
    public Translator searchbByANAMEtrans(String name) {
        return dao.searchbByANAMEtrans(name);
    }

    @Override
    public Author searchbByASURNAME(String surname) {
       return dao.searchbByASURNAME(surname);
    }

    @Override
    public Reference addPublisher(int oldPubID, int RefID,String SelectedReferencePub,String SelectedReferencePubcountry) {
        return dao.addPublisher(oldPubID,RefID,SelectedReferencePub,SelectedReferencePubcountry); 
    }

    @Override 
    public void addRefBig(Reference r, String email) {
        dao.addRefBig(r,email);  
    }

    @Override
    public boolean UserExist(int id,String email) {
        return dao.UserExist(id, email);
    }

    @Override
    public void updateUser(int id,String name, String email, String password) {
        dao.updateUser(  id,name,  email,  password);
    }

    @Override
    public List<Author> getallAuthors(int id) {
        return dao.getallAuthors(id);
    }

    @Override
    public void deleteAuthor(String email, int id) {
       dao.deleteAuthor(email,id);
    }

    @Override
    public void updateAuthor(Author a) {
        dao.updateAuthor(a);
    }

    @Override
    public List<Reference> getAllRef(int id) {
        return dao.getAllRef(id);
    } 

    @Override
    public List<Author> getAllAuthors() {
        return dao.getAllAuthors();
    }
    
    @Override
        public void deleteReference(String email, int id) {
                dao.deleteReference(email, id);
        }

        @Override
        public void updateReference(Reference r) {
                dao.updateReference(r);
        }

    @Override
    public void deletePub(String Pname, String Pcountry, Reference r) {
            dao.deletePub(Pname, Pcountry, r);
    }

    @Override
    public Reference linkAuthor(Reference selectedReference, Author newAuthor) {
        return dao.linkAuthor(selectedReference, newAuthor);
    }

    @Override
    public Reference linkTAuthor(Reference selectedReference, Translator translator ) {
       return dao.linkTAuthor(selectedReference, translator);
    }

    @Override
    public Reference unlinkAuthor(Reference selectedReference, Author selectedAuthor) {
         return dao.unlinkAuthor(selectedReference, selectedAuthor);
    }

    @Override
    public Reference unlinkTAuthor(Reference selectedReference, Translator selectedTranslator) {
        return dao.unlinkTAuthor(selectedReference, selectedTranslator);
    }  
        
    @Override
    public AccUser addAcademicSet(int userId, String academicSetName)
    {
         return dao.addAcademicSet(userId, academicSetName);
    }
       @Override
    public List<AcademicSet> getAllAcademicSets(int id)
       {
           return dao.getAllAcademicSets(id);
       }

    @Override
    public AcademicSet removeRefToSet(AcademicSet selectedAcademicSet, Reference selectedSetReference) {
        return dao.removeRefToSet(selectedAcademicSet, selectedSetReference);
    }

    @Override
    public AcademicSet addRefToSet(AcademicSet selectedSet, Reference selectedRef) {
        return dao.addRefToSet(selectedSet, selectedRef);
    }

    @Override
    public void deleteSelectedAcademicSet(AcademicSet selectedAcademicSet, AccUser current) {
        dao.deleteSelectedAcademicSet(selectedAcademicSet, current);
    }

    @Override
    public void renameSelectedAcademicSet(AcademicSet selSet, String selectedAcademicSetName) {
        dao.renameSelectedAcademicSet(selSet,selectedAcademicSetName);
    }

        @Override
        public List<Format> allFormats(int id) {
                return dao.allFormats(id);
        }

        @Override
        public AccUser addFormat(int l, Format f) {
               return dao.addFormat( l, f);
        }

        @Override
        public void deleteSelectedFormat(Format selectedFormat, AccUser current) {
                dao.deleteSelectedFormat( selectedFormat,  current);
        }

    @Override
    public void renameSelectedFormat(Format selFOR, String selectedFormatName) {
        dao.renameSelectedFormat(selFOR, selectedFormatName);
    }
	

   

}
